//
//  GJFCollecionViewController.m
//  Wedding
//
//  Created by 郭静芬 on 2017/1/12.
//  Copyright © 2017年 郭静芬. All rights reserved.
//

#import "GJFCollecionViewController.h"
#import "GJFMineCollectionTableViewCell.h"
#import "GJFMerchantCollectViewController.h"
#import "GJFVideoCollectViewController.h"
#import "GJFCaseCollectViewController.h"

@interface GJFCollecionViewController () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@end

@implementation GJFCollecionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"我的收藏";
    [self tableView];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    GJFMineCollectionTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CollectCell"];
    if (indexPath.section == 0) {
        cell.imageV.image = [UIImage imageNamed:@"案例收藏"];
        cell.label.text = @"案例收藏";
    }
    else if (indexPath.section == 1) {
        cell.imageV.image = [UIImage imageNamed:@"视频收藏"];
        cell.label.text = @"视频收藏";
    }
    else{
        cell.imageV.image = [UIImage imageNamed:@"商户收藏"];
        cell.label.text = @"商户收藏";
    }
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 90 * YY;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 20 * YY;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.01;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        GJFCaseCollectViewController *caseCollect = [[GJFCaseCollectViewController alloc] init];
        [self.navigationController pushViewController:caseCollect animated:YES];
    }
    else if (indexPath.section == 1) {
        GJFVideoCollectViewController *videoollect = [[GJFVideoCollectViewController alloc] init];
        [self.navigationController pushViewController:videoollect animated:YES];
    }
    else {
        GJFMerchantCollectViewController *merchantCollect = [[GJFMerchantCollectViewController alloc] init];
        [self.navigationController pushViewController:merchantCollect animated:YES];
    }
}

- (UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT) style:UITableViewStyleGrouped];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        
        [_tableView registerClass:[GJFMineCollectionTableViewCell class] forCellReuseIdentifier:@"CollectCell"];
        
        [self.view addSubview:_tableView];
    }
        return _tableView;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
